﻿<!doctype html>
<html><!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>会员类型统计</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/sub.js"></script><!-- 标签切换 -->
<script type="text/javascript" src="../js/gbRst.js"></script>
	<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/highcharts.js"></script>
<script type="text/javascript" src="../js/exporting_1.js"></script>
<script type="text/javascript" src="../js/huituUtils.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script> 
<link href="../css/style.css" type="text/css" rel="stylesheet" />

<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->


</head>

<body>
<!-- InstanceBeginEditable name="EditRegion3" -->
<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
<script type="text/javascript">
$(function(){	
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "0"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});
});
$(function(){
	checkNowYear(30);
	$("#nowYear").change(function(){
		findMemberCount()
	})
})
function checkNowYear(num){
	
	var nowYear=2014
	var domDiv;
	for(var i=0;i<num;i++){
		var domDiv=domDiv+"<option>"+nowYear+"</option>";
		var nowYear=nowYear-1;
	}
	$("#nowYear").prepend(domDiv);	
}//选年份的下拉框
</script>

<script type="text/javascript">
		var year = null
			
			$(document).ready(function() {
				var year = new Date()
					/* 	$.ajax({
						type : "get",
						datatype : "json",
						url : "../member/find/memberCount",
						data : {'year':year},
						success : function(data) {
							var rst = JSON.parse(data);
								if(rst.state==0){
									 	$("#allCount").html(rst.result.data[0][0])
									 	$("#yesCount").html(rst.result.data[0][1])
									}
						}	
					});
					
				var now=new Date();
				endTime=now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
				$("#dtEnd").val(endTime)	
				now.setTime(now.getTime()-30*24*3600*1000);
				beginTime=now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
				$("#dtBegin").val(beginTime)	 */
			
				findMemberCount()
			});
			
			
			function findMemberCount(){
				var year = $("#nowYear").val()
		
				/* var beginTime=$("#dtBegin").val();
				var endTime = $("#dtEnd").val();
				var param="timeBegin="+beginTime+"&timeEnd="+endTime; */
				$.ajax({
						type : "get",
						async:false,
						datatype : "json",
						data:{'year':year},
						url : "../member/find/memberType",
						success : function(data) {
							var rst = JSON.parse(data);
									if(IsEmpty(rst)){
										art.dialog({fixed:true, lock: true,content:"查询错误",icon:'error',ok:true});	
										return false;
										}
										if(rst.state==0){
									makeParam(rst);
									}else if(rst.state==1){
									art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
									}else{
											checkStateShowErrorMsgAndDealResult(data);
									}			
									
									
						}	
					});
				
			}
			
			function makeParam(json){
				var param = [];
				var all = 0;
				$("#memberList1 tbody ").empty();
				var allM1=0;
				var allM2=0;
				var allM3=0;
				var allM4=0;
				var allM5=0;
				var allM6=0;
				var allM7=0;
				var allM8=0;
				var allM9=0;
				var allM10=0;
				var allM11=0;
				var allM12=0;
				for(m=0;m<json.result.data.length;m++){
					var typeName = getHeadIndexValue(m, json, "typeName");
					var count=getHtmlInt( getHeadIndexValue(m, json, "count")) 
					var mCount = getHtmlInt( getHeadIndexValue(m, json, "mCount"))
					var m1 = getHtmlInt( getHeadIndexValue(m, json, "m1"))
					var m2 = getHtmlInt( getHeadIndexValue(m, json, "m2"))
					var m3 = getHtmlInt( getHeadIndexValue(m, json, "m3"))
					var m4 = getHtmlInt( getHeadIndexValue(m, json, "m4"))
					var m5 = getHtmlInt( getHeadIndexValue(m, json, "m5"))
					var m6 = getHtmlInt( getHeadIndexValue(m, json, "m6"))
					var m7 = getHtmlInt( getHeadIndexValue(m, json, "m7"))
					var m8 = getHtmlInt( getHeadIndexValue(m, json, "m8"))
					var m9 = getHtmlInt( getHeadIndexValue(m, json, "m9"))
					var m10 = getHtmlInt( getHeadIndexValue(m, json, "m10"))
					var m11 = getHtmlInt( getHeadIndexValue(m, json, "m11"))
					var m12 = getHtmlInt( getHeadIndexValue(m, json, "m12"))
					if(IsEmpty(typeName)){
						typeName="其它"
					}
					var  datas={'name':typeName,'data':[m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12]}
					param[m]=datas
					all +=count;
					allM1+=m1;
					allM2+=m2;
					allM3+=m3;
					allM4+=m4;
					allM5+=m5;
					allM6+=m6;
					allM7+=m7;
					allM8+=m8;
					allM9+=m9;
					allM10+=m10;
					allM11+=m11;
					allM12+=m12;					
					}
				
				
				for(m=0;m<json.result.data.length;m++){
					var typeName = getHeadIndexValue(m, json, "typeName");
					var count =getHtmlInt( getHeadIndexValue(m, json, "count")) 
					
					var m1 = getHtmlInt( getHeadIndexValue(m, json, "m1"))
					var m2 = getHtmlInt( getHeadIndexValue(m, json, "m2"))
					var m3 = getHtmlInt( getHeadIndexValue(m, json, "m3"))
					var m4 = getHtmlInt( getHeadIndexValue(m, json, "m4"))
					var m5 = getHtmlInt( getHeadIndexValue(m, json, "m5"))
					var m6 = getHtmlInt( getHeadIndexValue(m, json, "m6"))
					var m7 = getHtmlInt( getHeadIndexValue(m, json, "m7"))
					var m8 = getHtmlInt( getHeadIndexValue(m, json, "m8"))
					var m9 = getHtmlInt( getHeadIndexValue(m, json, "m9"))
					var m10 = getHtmlInt( getHeadIndexValue(m, json, "m10"))
					var m11 = getHtmlInt( getHeadIndexValue(m, json, "m11"))
					var m12 = getHtmlInt( getHeadIndexValue(m, json, "m12"))
					if(IsEmpty(typeName)){
						typeName="其它"
					}
					$("#memberList1 tbody ").prepend("<tr></tr>");
					
					var value = jisuan(count, all, 1);
					$("#memberList1 tbody tr:first")
					.append("<td>"+typeName+"</td>")
					.append("<td>"+m1+"</td>")
					.append("<td>"+m2+"</td>")
					.append("<td>"+m3+"</td>")
					.append("<td>"+m4+"</td>")
					.append("<td>"+m5+"</td>")
					.append("<td>"+m6+"</td>")
					.append("<td>"+m7+"</td>")
					.append("<td>"+m8+"</td>")
					.append("<td>"+m9+"</td>")
					.append("<td>"+m10+"</td>")
					.append("<td>"+m11+"</td>")
					.append("<td>"+m12+"</td>")
					.append("<td>"+count+"</td>").append("<td>"+value+"</td>")
					
				}
				
				$("#memberList1 tbody ").append("<tr></tr>");
				
				$("#memberList1 tbody tr:last")
				
					.append("<td>总计</td>")
					.append("<td>"+allM1+"</td>")
					.append("<td>"+allM2+"</td>")
					.append("<td>"+allM3+"</td>")
					.append("<td>"+allM4+"</td>")
					.append("<td>"+allM5+"</td>")
					.append("<td>"+allM6+"</td>")
					.append("<td>"+allM7+"</td>")
					.append("<td>"+allM8+"</td>")
					.append("<td>"+allM9+"</td>")
					.append("<td>"+allM10+"</td>")
					.append("<td>"+allM11+"</td>")
					.append("<td>"+allM12+"</td>")
					.append("<td>"+all+"</td><td>100%</td>")
				//huitu("container1", param, "车辆统计", "所占比例：");
				var x =['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
					huitu_zhu("container1", param, "会员类型统计", "数量", "ok",x )

				//highChars(param,"新注册会员统计","注册数：");
			}
			
			function jisuan(num1,num2,xiaoshu){
				var c = num1/num2*100;
				return parseFloat(c).toFixed(xiaoshu)+"%"
			}
			/* function highChars(param,title,name){//绘图
			 var s=	new Highcharts.StockChart({
					chart: {
						renderTo: 'container1',
						marginRight: 30,
						marginBottom: 25
					},
				 credits:{
					 enabled :false
				 },
				 
					exporting:{
						enabled:false,
						show:false
					},
					rangeSelector: {
						show:false,
						enable:true,
				        buttons: [{
				            type: 'day',
				            count: 3,
				            text: '3天'
				        }, {
				            type: 'week',
				            count: 1,
				            text: '1周'
				        }, {
				            type: 'month',
				            count: 1,
				            text: '1个月'
				        }, {
				            type: 'month',
				            count: 6,
				            text: '6个月'
				        }, {
				            type: 'year',
				            count: 1,
				            text: '1年'
				        }, {
				            type: 'all',
				            text: '所有'
				        }],
				        selected: 6
				    },
					title: {
						text: title
						
					},
					subtitle: {
						text: ''
						
					},
					xAxis:{
			            labels: {  
			            formatter: function() {  
			                var vDate=new Date(this.value);  
			                return (vDate.getMonth()+1)+"-"+vDate.getDate();  
			            },
			            maxStaggerLines:3
						},
						minRange:7*24*3600*1000
						},
					yAxis: {
						title: {
							text: ''
						},
						plotLines: [{
							value: 0,
							width: 1,
							color: '#808080'
						}],
						min:0
					},
					 tooltip: {  
				            xDateFormat: '%Y-%m-%d'//鼠标移动到趋势线上时显示的日期格式  
				        },  
					legend: {
						layout: 'vertical',
						align: 'right',
						verticalAlign: 'top',
						x: -10,
						y: 100,
						borderWidth: 0
					},
					series: [{
						name: name,
						data: param,
						 pointInterval: 24*3600 * 1000,
					        tooltip: {
					        	valueSuffix: '人'
					        }
					}]
				});
			 	
			} */
				
	$(function(){
		$("#sub_s1").click(function(){
			findMemberCount(1)
			$("#search_btn2").hide()
			$("#search_btn1").show();
			$(this).addClass("focus");
			$("#sub_s2").removeClass("focus");
		})
		$("#sub_s2").click(function(){
			findMemberCount(2)
			$("#search_btn1").hide()
			$("#search_btn2").show();
			$(this).addClass("focus");
			$("#sub_s1").removeClass("focus");
		})
	})		
		</script><!-- 折线图 -->
<div class="container" id="container">
  <div class="container_R fr">
	<div class="place">会员类型统计</div>
    <!-- <div class="shadow yesterday_all">
    	<h2 class="title">会员统计</h2>
        <ul class="main_number">
        	<li class="noBorder"><strong >新会员</strong><span id="yesCount"></span></li>
        	<li><strong>总会员</strong><span id="allCount"></span></li>
        </ul>
        <div class="fc"></div>
    </div> -->
    <div class="member_search"><select id="nowYear"></select></div>
    <div class="shadow yesterday_all" id="bigBox">
<!--     	<h2 class="title">关键指标详解<div id="sub"><span class="focus" id="sub_s1">新增会员</span><span id="sub_s2">累积会员</span></div></h2>
 --><!--     	<div class="search_term"><span>起始日期：</span><input type="text" readonly class="doubledate ipticon"  id="dtBegin"/><span>截止时间：</span><input type="text" readonly class="doubledate ipticon" id="dtEnd"/><input type="button" id="search_btn1" class="search_btn common_btn" onclick="findMemberCount(1)" value="查询"><input type="button" id="search_btn2" style="display: none;" class="search_btn common_btn" onclick="findMemberCount(2)" value="查询"></div>
 -->        	<div class="box_img">
            	<h4>统计图</h4>
                <div class="line_img"><div id="container1" style="width: 100%; height: 400px; margin: 0 auto"></div></div>
            </div>
            
          <div>
           <table  width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList1">
    	<thead>
    	<tr>
        	<th>会员类型</th>
        	<th>1月</th>
        	<th>2月</th>
        	<th>3月</th>
        	<th>4月</th>
        	<th>5月</th>
        	<th>6月</th>
        	<th>7月</th>
        	<th>8月</th>
        	<th>9月</th>
        	<th>10月</th>
        	<th>11月</th>
        	<th>12月</th>
        	<th>小计</th>
        	<th>占比 </th>
        </tr>
        </thead>
    	<tbody></tbody>
    </table>
          </div>   
        	   
    </div>
  </div>
  <div class="fc"></div>
</div>
<script type="text/javascript">

</script>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/header.js"></script>
<script type="text/javascript" src="../js/left.js"></script>
<script type="text/javascript" src="../js/footer.js"></script>
<script type="text/javascript">
showTab(9,2);
</script>
</body>
<!-- InstanceEnd --></html>
